package com.sikaryofficial.backend.config;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.stream.Collectors;

/**
 * @author : qinjinyuan
 * @desc : 店铺相关配置
 * @date : 2024/06/03 13:36
 */
@Getter
@Setter
@Configuration
@RefreshScope
@ConfigurationProperties(prefix = "hismk.backend.store")
public class StoreConfig {
    private String saleOwnerProducts;

    private List<Integer> distance;

    private List<String> shopType;

    private List<String> sortType;

    public List<String> getSaleOwnerProducts() {
        if (saleOwnerProducts == null || saleOwnerProducts.isEmpty()) {
            return new ArrayList<>();
        }
        ArrayBlockingQueue<String> queue = new ArrayBlockingQueue<>(saleOwnerProducts.length());
        return Arrays.stream(saleOwnerProducts.split(","))
                .map(String::trim) // 去除前后空格
                .filter(s -> !s.isEmpty()) // 过滤掉空字符串
                .collect(Collectors.toList());
    }
}
